
#include <cstdlib>
#include <uv.h>

void entry(void *arg) 
{
    uv_loop_t *thread_loop = (uv_loop_t *)malloc(sizeof(uv_loop_t));
    uv_loop_init(thread_loop);

    uv_run(thread_loop, UV_RUN_DEFAULT);
    uv_loop_close(thread_loop);
    free(thread_loop);

}

int main()
{
    uv_loop_t *main_loop = (uv_loop_t *)malloc(sizeof(uv_loop_t));
    uv_loop_init(main_loop);

    uv_thread_t thrd;
    uv_thread_create(&thrd, entry, main_loop);

    uv_run(main_loop, UV_RUN_DEFAULT);

    uv_thread_join(&thrd);
    uv_loop_close(main_loop);
    free(main_loop);

    return 0;
}
